﻿using Coldairarrow.Business.Base;
using Coldairarrow.Entity.Base;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base
{
    [Route("/Base/[controller]/[action]")]
    public class Base_RegistrationController : BaseApiController
    {
        #region DI

        public Base_RegistrationController(IBase_RegistrationBusiness base_RegistrationBus)
        {
            _base_RegistrationBus = base_RegistrationBus;
        }

        IBase_RegistrationBusiness _base_RegistrationBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_Registration>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_RegistrationBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_Registration> GetTheData(IdInputDTO input)
        {
            return await _base_RegistrationBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 获取看板列表信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<Base_RegistrationDto>> GetDataQueryList(PageInput<Base_RegistrationCondition> input) {

            var list= await _base_RegistrationBus.GetBase_RegistrationList(input);
            return list;
        }

        #endregion

        #region 提交
        [HttpPost]
        public async Task SaveData(Base_Registration data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                data.Deleted = false;
                InitEntity(data);

                await _base_RegistrationBus.AddDataAsync(data);
            }
            else
            {
                await _base_RegistrationBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_RegistrationBus.DeleteDataAsync(ids);
        }

        /// <summary>
        /// 获取当前看板所在的组织
        /// </summary>
        /// <param name="DeviceId"></param>
        /// <returns></returns>
        [HttpGet]
        [NoCheckJWT]
        public async Task<Base_RegistrationDtoDeptList> GetRegistrationDtoDeptList(string DeviceId) {

            var data=await _base_RegistrationBus.GetRegistrationDtoDeptList(DeviceId);
            return data;
        }
        #endregion
    }
}